import { IsIn, IsOptional, IsString, Length } from 'class-validator';
import { $enum } from 'ts-enum-util';
import { AccessEntity } from '../entities/access.entity';

export enum StatusValue {
  /** 模块 */
  MOKUAI = 1,
  /** 菜单 */
  CAIDAN = 2,
  /** 操作 */
  CAOZUO = 3,
}

export class CreateAccessDto {
  readonly id: string;
  @IsString()
  @Length(2, 20, { message: 'name的长度不能小于2不能大于20' })
  readonly module_name: string;
  readonly url: string;
  readonly sort: number;
  @IsOptional()
  @IsIn($enum(StatusValue).getValues())
  readonly type?: StatusValue;
  @IsOptional()
  readonly parent?: AccessEntity;
  readonly children: AccessEntity[];
  readonly created_at: string;
  readonly updated_at: string;
}
